package com.xm.servlet.background.commodity;

import com.google.gson.Gson;
import com.xm.service.background.ClassService;
import lombok.SneakyThrows;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 商品类别
 * @author 康文程
 * @date 2024-1-20 下午 03:15
 */
@WebServlet("/background/get/find/class/by/category/id")
public class GetFindClassByCategoryIdServlet extends HttpServlet {
    private final ClassService service = new ClassService();

    @SneakyThrows
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
        resp.setContentType("text/html;charset=UTF-8");
        String categoryId = req.getParameter("categoryId");
        resp.getWriter().print(new Gson().toJson(service.findClassByCategoryId(Integer.parseInt(categoryId))));
    }
}
